//
// Created by zhou on 2021/10/20.
//
#include "iostream"
#include <vector>
#include <string>
#include <stack>
using namespace std;
class Solution {
public:
    string reverseWords1(string s) {
        int fast=0,slow=0;
        int size=s.length();
        int i=0;
        while(i<size){
            int start=i;
            while(i<size&&s[i]!=' '){
                i++;
            }
            int left=start;int right=i-1;
            while(left<right){
                swap(s[left],s[right]);
                left++;
                right--;
            }
            if(s[i]==' '&&i<size){
                i++;
            }
        }
        return s;
        }





};
int main(){
    Solution solution;
    string s="hello, my name is zhou hui! sab";
    cout<<solution.reverseWords1(s);

}